(function () {
    $('#submit').on('click', function () {
        var usrAccount = $('#usrAccount').val();
        var usrPassword = $('#usrPassword').val();
        if (!/^\w{2,16}$/.test(usrAccount)){
            layer.tips('账号不正确！', '#usrAccount', {tips:[1,'rgba(0,0,0,0.5)'], time:3000})
            return;
        }
        if (!/^\w{2,16}$/.test(usrPassword)){
            layer.tips('密码不正确！', '#usrPassword', {tips:[1,'rgba(0,0,0,0.5)'], time:3000})
            return;
        }
        $.ajax({
            url: '/login',
            method: 'post',
            data: {usrAccount: usrAccount, usrPassword: usrPassword},
            success: function (jsonResult) {
                if (jsonResult.status == 1) {
                    location.href = '/'
                }
                else layer.msg(jsonResult.message, {icon: 5})
            },
            error: function () {
                layer.msg('服务器异常！')
            }
        })
    })
})();